package com.lecture.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lecture.entity.BusinessIndicators;
import com.lecture.entity.BusinessIndicatorsParam;
import com.lecture.mapper.BusinessIndicatorsMapper;
import com.lecture.service.BusinessIndicatorsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 经营指标表 服务实现类
 * </p>
 *
 * @author luyn
 * @since 2025-03-14
 */
@Service
public class BusinessIndicatorsServiceImpl extends ServiceImpl<BusinessIndicatorsMapper, BusinessIndicators> implements BusinessIndicatorsService {

    @Override
    public List<BusinessIndicators> getBusinessIndicatorsList(BusinessIndicatorsParam param) {
        QueryWrapper<BusinessIndicators> queryWrapper = new QueryWrapper<>();
        /*if (Func.isNotEmpty(param.getPowerGenerationMin()) && Func.isNotEmpty(param.getPowerGenerationMax())) {
            queryWrapper.between("power_generation_thermal", param.getPowerGenerationMin(), param.getPowerGenerationMax());
        } else if (Func.isNotEmpty(param.getPowerGenerationMin())) {
            queryWrapper.gt("power_generation_thermal", param.getPowerGenerationMin());
        } else if (Func.isNotEmpty(param.getPowerGenerationMax())) {
            queryWrapper.lt("power_generation_thermal", param.getPowerGenerationMax());
        }

        if (Func.isNotEmpty(param.getGridPowerMin()) && Func.isNotEmpty(param.getGridPowerMax())) {
            queryWrapper.between("grid_power", param.getGridPowerMin(), param.getGridPowerMax());
        } else if (Func.isNotEmpty(param.getGridPowerMin())) {
            queryWrapper.gt("grid_power", param.getGridPowerMin());
        } else if (Func.isNotEmpty(param.getGridPowerMax())) {
            queryWrapper.lt("grid_power", param.getGridPowerMax());
        }

        if (Func.isNotEmpty(param.getLoadFactorMin()) && Func.isNotEmpty(param.getLoadFactorMax())) {
            queryWrapper.between("load_factor", param.getLoadFactorMin(), param.getLoadFactorMax());
        } else if (Func.isNotEmpty(param.getLoadFactorMin())) {
            queryWrapper.gt("load_factor", param.getLoadFactorMin());
        } else if (Func.isNotEmpty(param.getLoadFactorMax())) {
            queryWrapper.lt("load_factor", param.getLoadFactorMax());
        }

        if (Func.isNotEmpty(param.getPlantPowerConsumptionMin()) && Func.isNotEmpty(param.getPlantPowerConsumptionMax())) {
            queryWrapper.between("plant_power_consumption", param.getPlantPowerConsumptionMin(), param.getPlantPowerConsumptionMax());
        } else if (Func.isNotEmpty(param.getPlantPowerConsumptionMin())) {
            queryWrapper.gt("plant_power_consumption", param.getPlantPowerConsumptionMin());
        } else if (Func.isNotEmpty(param.getPlantPowerConsumptionMax())) {
            queryWrapper.lt("plant_power_consumption", param.getPlantPowerConsumptionMax());
        }

        if (Func.isNotEmpty(param.getHeatingPowerMin()) && Func.isNotEmpty(param.getHeatingPowerMax())) {
            queryWrapper.between("heating_power", param.getHeatingPowerMin(), param.getHeatingPowerMax());
        } else if (Func.isNotEmpty(param.getHeatingPowerMin())) {
            queryWrapper.gt("heating_power", param.getHeatingPowerMin());
        } else if (Func.isNotEmpty(param.getHeatingPowerMax())) {
            queryWrapper.lt("heating_power", param.getHeatingPowerMax());
        }

        if (Func.isNotEmpty(param.getHeatingWaterMin()) && Func.isNotEmpty(param.getHeatingWaterMax())) {
            queryWrapper.between("heating_water", param.getHeatingWaterMin(), param.getHeatingWaterMax());
        } else if (Func.isNotEmpty(param.getHeatingWaterMin())) {
            queryWrapper.gt("heating_water", param.getHeatingWaterMin());
        } else if (Func.isNotEmpty(param.getHeatingWaterMax())) {
            queryWrapper.lt("heating_water", param.getHeatingWaterMax());
        }


        if (Func.isNotEmpty(param.getRawWaterSupplyMin()) && Func.isNotEmpty(param.getRawWaterSupplyMax())) {
            queryWrapper.between("raw_water_supply", param.getRawWaterSupplyMin(), param.getRawWaterSupplyMax());
        } else if (Func.isNotEmpty(param.getRawWaterSupplyMin())) {
            queryWrapper.gt("raw_water_supply", param.getRawWaterSupplyMin());
        } else if (Func.isNotEmpty(param.getRawWaterSupplyMax())) {
            queryWrapper.lt("raw_water_supply", param.getRawWaterSupplyMax());
        }

        if (Func.isNotEmpty(param.getCompressedAirSupplyMin()) && Func.isNotEmpty(param.getCompressedAirSupplyMax())) {
            queryWrapper.between("compressed_air_supply", param.getCompressedAirSupplyMin(), param.getCompressedAirSupplyMax());
        } else if (Func.isNotEmpty(param.getCompressedAirSupplyMin())) {
            queryWrapper.gt("compressed_air_supply", param.getCompressedAirSupplyMin());
        } else if (Func.isNotEmpty(param.getCompressedAirSupplyMax())) {
            queryWrapper.lt("compressed_air_supply", param.getCompressedAirSupplyMax());
        }

        if (Func.isNotEmpty(param.getDailyCoalConsumptionMin()) && Func.isNotEmpty(param.getDailyCoalConsumptionMax())) {
            queryWrapper.between("daily_coal_consumption", param.getDailyCoalConsumptionMin(), param.getDailyCoalConsumptionMax());
        } else if (Func.isNotEmpty(param.getDailyCoalConsumptionMin())) {
            queryWrapper.gt("daily_coal_consumption", param.getDailyCoalConsumptionMin());
        } else if (Func.isNotEmpty(param.getDailyCoalConsumptionMax())) {
            queryWrapper.lt("daily_coal_consumption", param.getDailyCoalConsumptionMax());
        }

        if (Func.isNotEmpty(param.getDailyCoalInputMin()) && Func.isNotEmpty(param.getDailyCoalInputMax())) {
            queryWrapper.between("daily_coal_input", param.getDailyCoalInputMin(), param.getDailyCoalInputMax());
        } else if (Func.isNotEmpty(param.getDailyCoalInputMin())) {
            queryWrapper.gt("daily_coal_input", param.getDailyCoalInputMin());
        } else if (Func.isNotEmpty(param.getDailyCoalInputMax())) {
            queryWrapper.lt("daily_coal_input", param.getDailyCoalInputMax());
        }

        if (Func.isNotEmpty(param.getPowerCoalConsumptionMin()) && Func.isNotEmpty(param.getPowerCoalConsumptionMax())) {
            queryWrapper.between("power_coal_consumption", param.getPowerCoalConsumptionMin(), param.getPowerCoalConsumptionMax());
        } else if (Func.isNotEmpty(param.getPowerCoalConsumptionMin())) {
            queryWrapper.gt("power_coal_consumption", param.getPowerCoalConsumptionMin());
        } else if (Func.isNotEmpty(param.getPowerCoalConsumptionMax())) {
            queryWrapper.lt("power_coal_consumption", param.getPowerCoalConsumptionMax());
        }

        if (Func.isNotEmpty(param.getCoalStockMin()) && Func.isNotEmpty(param.getCoalStockMax())) {
            queryWrapper.between("coal_stock", param.getCoalStockMin(), param.getCoalStockMax());
        } else if (Func.isNotEmpty(param.getCoalStockMin())) {
            queryWrapper.gt("coal_stock", param.getCoalStockMin());
        } else if (Func.isNotEmpty(param.getCoalStockMax())) {
            queryWrapper.lt("coal_stock", param.getCoalStockMax());
        }

        if (Func.isNotEmpty(param.getCoalPortLoadingMin()) && Func.isNotEmpty(param.getCoalPortLoadingMax())) {
            queryWrapper.between("coal_port_loading", param.getCoalPortLoadingMin(), param.getCoalPortLoadingMax());
        } else if (Func.isNotEmpty(param.getCoalPortLoadingMin())) {
            queryWrapper.gt("coal_port_loading", param.getCoalPortLoadingMin());
        } else if (Func.isNotEmpty(param.getCoalPortLoadingMax())) {
            queryWrapper.lt("coal_port_loading", param.getCoalPortLoadingMax());
        }

        if (Func.isNotEmpty(param.getImportedCoalMin()) && Func.isNotEmpty(param.getImportedCoalMax())) {
            queryWrapper.between("imported_coal", param.getImportedCoalMin(), param.getImportedCoalMax());
        } else if (Func.isNotEmpty(param.getImportedCoalMin())) {
            queryWrapper.gt("imported_coal", param.getImportedCoalMin());
        } else if (Func.isNotEmpty(param.getImportedCoalMax())) {
            queryWrapper.lt("imported_coal", param.getImportedCoalMax());
        }

        if (Func.isNotEmpty(param.getElectricityHeatUnitCostMin()) && Func.isNotEmpty(param.getElectricityHeatUnitCostMax())) {
            queryWrapper.between("electricity_heat_unit_cost", param.getElectricityHeatUnitCostMin(), param.getElectricityHeatUnitCostMax());
        } else if (Func.isNotEmpty(param.getElectricityHeatUnitCostMin())) {
            queryWrapper.gt("electricity_heat_unit_cost", param.getElectricityHeatUnitCostMin());
        } else if (Func.isNotEmpty(param.getElectricityHeatUnitCostMax())) {
            queryWrapper.lt("electricity_heat_unit_cost", param.getElectricityHeatUnitCostMax());
        }

        if (Func.isNotEmpty(param.getFactoryCoalPriceDiffMin()) && Func.isNotEmpty(param.getFactoryCoalPriceDiffMax())) {
            queryWrapper.between("factory_coal_price_diff", param.getFactoryCoalPriceDiffMin(), param.getFactoryCoalPriceDiffMax());
        } else if (Func.isNotEmpty(param.getFactoryCoalPriceDiffMin())) {
            queryWrapper.gt("factory_coal_price_diff", param.getFactoryCoalPriceDiffMin());
        } else if (Func.isNotEmpty(param.getFactoryCoalPriceDiffMax())) {
            queryWrapper.lt("factory_coal_price_diff", param.getFactoryCoalPriceDiffMax());
        }

        if (Func.isNotEmpty(param.getTransactionElectricityPriceMin()) && Func.isNotEmpty(param.getTransactionElectricityPriceMax())) {
            queryWrapper.between("transaction_electricity_price", param.getTransactionElectricityPriceMin(), param.getTransactionElectricityPriceMax());
        } else if (Func.isNotEmpty(param.getTransactionElectricityPriceMin())) {
            queryWrapper.gt("transaction_electricity_price", param.getTransactionElectricityPriceMin());
        } else if (Func.isNotEmpty(param.getTransactionElectricityPriceMax())) {
            queryWrapper.lt("transaction_electricity_price", param.getTransactionElectricityPriceMax());
        }

        if (Func.isNotEmpty(param.getTransactionElectricityMin()) && Func.isNotEmpty(param.getTransactionElectricityMax())) {
            queryWrapper.between("transaction_electricity", param.getTransactionElectricityMin(), param.getTransactionElectricityMax());
        } else if (Func.isNotEmpty(param.getTransactionElectricityMin())) {
            queryWrapper.gt("transaction_electricity", param.getTransactionElectricityMin());
        } else if (Func.isNotEmpty(param.getTransactionElectricityMax())) {
            queryWrapper.lt("transaction_electricity", param.getTransactionElectricityMax());
        }

        if (Func.isNotEmpty(param.getElectricitySalesMin()) && Func.isNotEmpty(param.getElectricitySalesMax())) {
            queryWrapper.between("electricity_sales", param.getElectricitySalesMin(), param.getElectricitySalesMax());
        } else if (Func.isNotEmpty(param.getElectricitySalesMin())) {
            queryWrapper.gt("electricity_sales", param.getElectricitySalesMin());
        } else if (Func.isNotEmpty(param.getElectricitySalesMax())) {
            queryWrapper.lt("electricity_sales", param.getElectricitySalesMax());
        }

        if (Func.isNotEmpty(param.getCapacityFeeMin()) && Func.isNotEmpty(param.getCapacityFeeMax())) {
            queryWrapper.between("capacity_fee", param.getCapacityFeeMin(), param.getCapacityFeeMax());
        } else if (Func.isNotEmpty(param.getCapacityFeeMin())) {
            queryWrapper.gt("capacity_fee", param.getCapacityFeeMin());
        } else if (Func.isNotEmpty(param.getCapacityFeeMax())) {
            queryWrapper.lt("capacity_fee", param.getCapacityFeeMax());
        }

        if (Func.isNotEmpty(param.getCarbonEmissionIndexMin()) && Func.isNotEmpty(param.getCarbonEmissionIndexMax())) {
            queryWrapper.between("carbon_emission_index", param.getCarbonEmissionIndexMin(), param.getCarbonEmissionIndexMax());
        } else if (Func.isNotEmpty(param.getCarbonEmissionIndexMin())) {
            queryWrapper.gt("carbon_emission_index", param.getCarbonEmissionIndexMin());
        } else if (Func.isNotEmpty(param.getCarbonEmissionIndexMax())) {
            queryWrapper.lt("carbon_emission_index", param.getCarbonEmissionIndexMax());
        }*/

        return list(queryWrapper);
    }
}
